import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';

export const columns: BasicColumn[] = [
  {
    title: '消息id',
    dataIndex: 'id',
    defaultHidden: true,
    align: 'center',
    width: 200,
  },
  {
    title: '发送人id',
    dataIndex: 'senderBy',
    defaultHidden: true,
    align: 'center',
    width: 200,
  },
  {
    title: '发送人姓名',
    dataIndex: 'senderByName',
    defaultHidden: true,
    align: 'center',
    width: 200,
  },
  {
    title: '接受人id',
    dataIndex: 'receiverBy',
    defaultHidden: true,
    align: 'center',
    width: 200,
  },
  {
    title: '接收人姓名',
    dataIndex: 'receiverByName',

    align: 'center',
    width: 200,
  },
  {
    title: '消息',
    dataIndex: 'content',
    align: 'center',
    width: 200,
  },
  {
    title: '处理状态',
    dataIndex: 'isHandle',
    customRender: ({ record }) => {
      const status = record.isHandle;
      let text = '';
      if (status == 0) {
        text = '未处理';
      } else {
        text = '已处理';
      }
      return h(() => text);
    },
    align: 'center',
    width: 200,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'id',
    label: '消息id',
    component: 'Input',
    ifShow: false,
    componentProps: {
      placeholder: '请输入消息id',
    },
    colProps: { span: 6 },
  },
  {
    field: 'receiverBy',
    label: '接受人id',
    component: 'Input',
    ifShow: false,
    componentProps: {
      placeholder: '请输入接受人id',
    },
    colProps: { span: 6 },
  },
  {
    field: 'senderByName',
    label: '发送人姓名',
    component: 'Input',
    show: true,
  },
  {
    field: 'receiverByName',
    label: '接收人姓名',
    component: 'Input',
    componentProps: {
      placeholder: '请输入接收人姓名',
    },
    colProps: { span: 6 },
  },
  {
    field: 'isHandle',
    label: '处理状态',
    component: 'Select',
    componentProps: {
      placeholder: '请选择状态',
      options: [
        { label: '未处理', value: 0 },
        { label: '未处理', value: 1 },
      ],
    },
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: '消息id',
    component: 'Input',
    show: false,
    required: false,

    componentProps: {
      disabled: false,
      placeholder: '请输入消息id',
    },
    colProps: { span: 12 },
  },
  {
    field: 'senderBy',
    label: '发送人id',
    component: 'Input',
    show: true,
    required: true,

    componentProps: {
      disabled: false,
      placeholder: '请输入发送人id',
    },
    colProps: { span: 12 },
  },
  {
    field: 'senderByName',
    label: '发送人姓名',
    component: 'Select',
    show: true,
    required: true,

    componentProps: {
      disabled: false,
      placeholder: '请选择发送人姓名',
      options: [
        {
          label: '12312',
          value: '3123',
        },
        {
          label: '123123',
          value: '123',
        },
        {
          label: '23123',
          value: '123',
        },
        {
          label: '3123123',
          value: '123',
        },
        {
          label: '123123',
          value: '123',
        },
        {
          label: '312',
          value: '3123',
        },
        {
          label: '123123',
          value: '123',
        },
        {
          label: '1231',
          value: '23123123',
        },
      ],
    },
    colProps: { span: 12 },
  },
  {
    field: 'receiverBy',
    label: '接受人id',
    component: 'Input',
    show: true,
    required: true,

    componentProps: {
      disabled: false,
      placeholder: '请输入接受人id',
    },
    colProps: { span: 12 },
  },
  {
    field: 'receiverByName',
    label: '接收人姓名',
    component: 'Input',
    show: true,
    required: true,

    componentProps: {
      disabled: false,
      placeholder: '请输入接收人姓名',
    },
    colProps: { span: 12 },
  },
  {
    field: 'isHandle',
    label: '是否处理',
    component: 'Switch',
    show: true,
    required: true,

    componentProps: {
      disabled: false,
      placeholder: '请输入是否处理',
    },
    colProps: { span: 12 },
  },
  {
    field: 'dateCreated',
    label: '创建时间',
    component: 'Input',
    show: false,
    required: true,

    componentProps: {
      disabled: false,
      placeholder: '请输入创建时间',
    },
    colProps: { span: 12 },
  },
  {
    field: 'dateModified',
    label: '修改时间',
    component: 'Input',
    show: false,
    required: false,

    componentProps: {
      disabled: false,
      placeholder: '请输入修改时间',
    },
    colProps: { span: 12 },
  },
  {
    field: 'createdBy',
    label: '创建人id',
    component: 'Input',
    show: false,
    required: true,

    componentProps: {
      disabled: false,
      placeholder: '请输入创建人id',
    },
    colProps: { span: 12 },
  },
  {
    field: 'createdByName',
    label: '创建人',
    component: 'Input',
    show: false,
    required: true,

    componentProps: {
      disabled: false,
      placeholder: '请输入创建人',
    },
    colProps: { span: 12 },
  },
  {
    field: 'modifiedBy',
    label: '修改人id',
    component: 'Input',
    show: false,
    required: false,

    componentProps: {
      disabled: false,
      placeholder: '请输入修改人id',
    },
    colProps: { span: 12 },
  },
  {
    field: 'modifiedByName',
    label: '修改人',
    component: 'Input',
    show: false,
    required: false,

    componentProps: {
      disabled: false,
      placeholder: '请输入修改人',
    },
    colProps: { span: 12 },
  },
];
